<template>
  <el-dialog :title="Add" :visible.sync="addDialogFormVisible">
    <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="temp.username" />
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="temp.password" />
      </el-form-item>
      <el-form-item label="电话" prop="telephone">
        <el-input v-model="temp.telephone" />
      </el-form-item>
      <el-form-item label="出生日期" prop="birthday">
        <el-date-picker v-model="temp.birthday" type="datetime" placeholder="Please pick a date" />
      </el-form-item>
      <el-form-item label="所属公司" prop="company">
        <el-input v-model="temp.company" />
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="temp.userStatus" class="filter-item" placeholder="Please select">
          <el-option v-for="item in statusOptions" :key="item" :label="statusCNMap[item]" :value="item" />
        </el-select>
      </el-form-item>
      <el-form-item label="职位" prop="position">
        <el-input v-model="temp.position" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="temp.remark" :autosize="{ minRows: 2, maxRows: 4}" type="textarea" placeholder="Please input" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">
        取消
      </el-button>
      <el-button type="primary" @click="createData">
        确定
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      // 对话框可见状态
      dialogFormVisible: false,
      dialogStatus: 'create',
      showPassword: true,
      // 表单数据
      dataForm: {
        id: undefined,
        position: '',
        username: '',
        remark: '',
        birthday: new Date(),
        company: '',
        telephone: '',
        userCharacter: '',
        userId: '',
        userStatus: 'published'
      }
    }
  },
  methods: {
    createData() {
      this.$emit('add', this.dataForm) // 发送事件给父组件
    }
  }
}
</script>
